package com.system.service.impl;

import java.util.List;

import com.base.service.impl.ServiceImpl;
import com.system.pojo.Dept;
import com.system.service.IDeptService;

public class DeptServiceImpl<T extends Dept> extends ServiceImpl<T> implements IDeptService<T> {

	@Override
	public boolean create(T dept) {
		if (dept.getId()!=null) {
			List<T> list = this.getDao().createQuery("select * from Dept as n where n.id ="+ dept.getId()).list();
			list.get(0).setDeptName(dept.getDeptName());
			list.get(0).setTopDept(dept.getTopDept());
			list.get(0).setUpDept(dept.getUpDept());
			list.get(0).setContent(dept.getContent());
			this.getDao().save(list.get(0));
			return false;
		} else {
			this.getDao().create(dept);
			return true;
		}
	}
}
